import { request } from '../utils/request';
import type { ApiResponse } from '../types/common';
import { ListParams, PhaseSummaryItem, PhaseSummaryDetail, GenerateSummaryParams } from '../types/phase-summary';

// API 方法
export const phaseSummaryApi = {
  // 获取阶段总结列表
  getSummaryList: (params: ListParams) => {
    return request.get<any, ApiResponse<{ count: number; results: PhaseSummaryItem[] }>>('/summary/', {
      params,
    });
  },

  // 获取阶段总结详情
  getSummaryDetail: (id: string) => {
    return request.get<any, ApiResponse<PhaseSummaryDetail>>(`/summary/${id}/`);
  },

  // 生成阶段总结报告
  generateSummary: (data: GenerateSummaryParams) => {
    return request.post<any, ApiResponse<PhaseSummaryItem>>('/summary/generate/', data);
  },

  // 删除阶段总结
  deleteSummary: (id: string) => {
    return request.delete<any, ApiResponse<null>>(`/summary/${id}/`);
  },

  // 下载阶段总结报告
  downloadSummaryReport: (id: string) => {
    return request.get<any, Blob>(`/summary/${id}/download/`, {
      responseType: 'blob',
    });
  },
};